package com.example.mysql.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.core.Result;
import com.example.mysql.entity.TblRecordLog;
import com.example.mysql.service.ITblRecordLogService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author developer
 * @since 2024-08-11
 */
@RestController
@RequestMapping("/tbl-record-log")
public class TblRecordLogController {
    @Resource
    private ITblRecordLogService iTblRecordLogService;

    @GetMapping("/id")
    public Result<List<TblRecordLog>> id(String id) {
        LambdaQueryWrapper<TblRecordLog> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TblRecordLog::getId, id);
        return Result.success(iTblRecordLogService.list(queryWrapper));
    }

    @GetMapping("/ids")
    public Result<List<TblRecordLog>> ids(String ids) {
        LambdaQueryWrapper<TblRecordLog> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(TblRecordLog::getId, StrUtil.split(ids, ","));
        return Result.success(iTblRecordLogService.list(queryWrapper));
    }

    @GetMapping("/list")
    public Result<List<TblRecordLog>> list() {
        return Result.success(iTblRecordLogService.list());
    }

    @GetMapping("/page")
    public Result<Page<TblRecordLog>> page(Page<TblRecordLog> page) {
        return Result.success(iTblRecordLogService.page(page));
    }
}
